package com.googlecode.gwtbb.client.only.remote.forum;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.googlecode.gwtbb.client.only.GwtUtils;
import com.googlecode.gwtbb.client.only.glue.events.GwtbbEvents;
import com.googlecode.gwtbb.client.only.remote.ClientResponseEventCallback;
import com.googlecode.gwtbb.client.shared.remote.forum.CreateForumBean;
import com.googlecode.gwtbb.client.shared.remote.forum.CreateForumResponse;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Apr 30, 2008
 */
public class ForumServiceProxy implements ForumServiceAsync {
	private static final ForumServiceProxy instance = new ForumServiceProxy();
	private ForumServiceAsync real = (ForumServiceAsync)GwtUtils.createProxy(GWT.create(ForumService.class), "/gwtbbExporter/forumService");

	public static ForumServiceProxy instance() {
		return instance;
	}

	public void create(Long userId, String sessionId, CreateForumBean createForumBean, final AsyncCallback async) {
		real.create(userId, sessionId, createForumBean, new ClientResponseEventCallback<CreateForumResponse>(async) {
			public void raiseEvent(CreateForumResponse serverResponse) {
				GwtbbEvents.instance().fireCreateForumEvent(serverResponse);
			}
		});
	}

	public void getForumThreadPosts(Long threadId, AsyncCallback async) {
		real.getForumThreadPosts(threadId, async);
	}

	public void getForumThreads(Long forumId, AsyncCallback async) {
		real.getForumThreads(forumId, async);
	}

	public void getForumsWithInfo(AsyncCallback async) {
		real.getForumsWithInfo(async);
	}
}
